<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List, member.MemberBean" %>
<%@page import="java.util.*"%>
<%
 	session.setAttribute("stage", "2");
	request.setCharacterEncoding("UTF-8");
%>
<jsp:include page="/share/layout.jsp" flush="true">
    <jsp:param name="title" value="利用者情報変更"/>
    <jsp:param name="css" value="member.css"/>
    <jsp:param name="content">
        <jsp:attribute name="value">

<!-- contents start -->

<div id="userEdit">

<%@ page import="java.sql.*"%>

<%
	MemberBean bean = (MemberBean)request.getAttribute("bean");
%>

<%-- エラーメッセージが設定されていればフィールドの枠を赤くする --%>
<%
	String error_user_id = (String)request.getAttribute("error_user_id");
	String error_password = (String)request.getAttribute("error_password");
	String error_name = (String)request.getAttribute("error_name");
	String error_ruby = (String)request.getAttribute("error_ruby");

	//取得できなければ空白を設定
	if(error_user_id == null || error_user_id.equals("")){
		error_user_id = "";
	}
	if(error_password == null || error_password.equals("")){
		error_password = "";
	}
	if(error_name == null || error_name.equals("")){
		error_name = "";
	}
	if(error_ruby == null || error_ruby.equals("")){
		error_ruby = "";
	}

	String error_class_user_id = null;
	String error_class_password = null;
	String error_class_name = null;
	String error_class_ruby = null;

	if(error_user_id.equals("error")){
		error_class_user_id = "class=\"red_frame\"";
	}else{
		error_class_user_id = "";
	}
	if(error_password.equals("error")){
		error_class_password = "class=\"red_frame\"";
	}else{
		error_class_password = "";
	}
	if(error_name.equals("error")){
		error_class_name = "class=\"red_frame\"";
	}else{
		error_class_name = "";
	}
	if(error_ruby.equals("error")){
		error_class_ruby = "class=\"red_frame\"";
	}else{
		error_class_ruby = "";
	}
 %>

 	<p class="error_message">
	<%-- エラーメッセージが設定されていれば表示 --%>
		<%
			@SuppressWarnings("unchecked")
			ArrayList<String> error = (ArrayList<String>)request.getAttribute("error_message");
			if(error != null && !error.equals("")){

				for( int i=0 ; i<error.size() ; i++ ){
		%>
				<%=error.get( i ) %><br />
		<%
				}
			}
		%>
	</p>

	<p>変更内容を入力して下さい</p>

	<form action="/Books/member/EditServlet" method="post">
		<table class="form_table">

			<tr>
				<th>ユーザー管理ID</th>
				<td><%=bean.getId() %><input type="hidden" name="id" value="<%= bean.getId() %>" /></td>
			</tr>
			<tr>
				<th>氏名</th>
				<td><input type="text" name="name" size="25" value="<%=bean.getName() %>" <%= error_class_name %>  maxlength="200" /></td>
			</tr>
			<tr>
				<th>フリガナ</th>
				<td><input type="text" name="ruby" size="25" value="<%=bean.getRuby() %>" <%= error_class_ruby %>  maxlength="300" /> <span class="small red">(※全角カタカナ)</span></td>
			</tr>
			<tr>
				<th>メールアドレス</th>
				<td><input type="text" name="user_id" size="25" value="<%=bean.getUserId() %>" <%= error_class_user_id %>  maxlength="300" /> <span class="small red">(※半角)</span></td>
			</tr>
			<tr>
				<th>パスワード</th>
				<td><input type="text" name="password" size="20" value="<%=bean.getPassword() %>" <%= error_class_password %>  maxlength="10" /> <span class="small red">(※半角)</span></td>
			</tr>

		</table>

		<div class="buttons">
			<input type="button" value="戻る" class="button" style="cursor:pointer" title="『利用者検索結果』へ" onClick="history.back(); return false;" />
	  		<input type="submit" value="確認" class="button" title="『利用者変更確認』へ" style="cursor:pointer" />
        </div>
</form>

</div>

<!-- contents end -->
        </jsp:attribute>
    </jsp:param>
</jsp:include>